package com.wen.Part6.GraphAlgorithm;

import com.wen.Part6.DataStructure.Graph;

public class GraphUtils {
    private GraphUtils(){}
    public static void printPath(Graph g, String start, int[] cost, int[] path){
        for (int i = 0; i < g.getSize(); i++) {
            System.out.print(String.format("%s 到 %s 开销为： <%d>  路径为：", start, g.index2Key(i), cost[i]));
            int pre = i;
            int startIndex = g.key2Index(start);
            System.out.print(g.index2Key(pre));
            while (pre != startIndex){
                pre = path[pre];
                System.out.print(" <-- " + g.index2Key(pre));
            }
            System.out.println();
        }
    }
}
